#ifndef SHIJU_OAM_MANAGER_H_INCLUDE
#define SHIJU_OAM_MANAGER_H_INCLUDE

#include "NmmToX86Protocol.h"
#include "OamMessageProtocol.h"
#include "BbuManager.h"
#include "ProcedureCtrl.h"
#include <arpa/inet.h>

#define OamManagerPtr (OamManager::instance())

class OamManager
{
public:
    static OamManager* instance();

    void processOamMessage(TlvMessage& tlvMsg, in_addr_t peerAddr);

    bool configCell(uint8_t slotId, uint16_t dlAfcn, uint16_t ulArfcn, uint16_t pci, uint16_t tac,
                    std::vector<uint32_t>& plmnList, 
                    const std::vector<uint16_t>& intraFreqPci, 
                    const std::vector<uint16_t>& interFreq,
                    int16_t* txPwPtr);
    bool UpdateCell(uint8_t slotId, std::vector<uint32_t>* plmnList, uint16_t* tac, uint16_t* earfcn, 
                                  uint16_t *ulEarfcn, bool* measEnablePtr);

    OamManager* setTrgByOam(bool);
    bool registerMsgHandler(TlvMessage::Protocol_t, TlvMessage::Signal_t signalType, EmBaseProcedure* proc);
private:
    OamManager();
    OamManager(const OamManager&);
    OamManager& operator=(const OamManager&);

    void processStdTxPowerDbGetRsp(OamMessageProtocol_TxPowerDbmStdGetRsp& msg, BbuCtrl& bbu);
    void processStdTxPowerGetRsp(OamMessageProtocol_TxPowerStdGetRsp& msg, BbuCtrl& bbu);
    void processStdTxPowerCfgRsp(OamMessageProtocol_TxPowerStdCfgRsp& msg, BbuCtrl& bbu);
    void processNmmDelayReport(OamMessageProtocol_NmmDelayReport& msg, BbuCtrl& bbu);
    void processInitNotification(NmmToX86Protocol_InitNotification& init, BbuCtrl&);
    void processInitCfgComp(OamMessageProtocol_InitCfgComp&, BbuCtrl&);
    void processHBAck(NmmToX86Protocol_HeartBeat& hbAck, BbuCtrl&);
    void processUeIdFilterRsp(OamMessageProtocol_UeIdFilterSwitchCfgRsp& rsp, BbuCtrl& bbu);
    void processTxPowerDbCfgRsp(OamMessageProtocol_TxPowerDbmConfigRsp& rsp, BbuCtrl& bbu);
    void processSoftwareVerRpt(OamMessageProtocol_VersionRpt&, uint32_t slotId);
    void processBbuStatusRpt(OamMessageProtocol_SysStatusRsp&, BbuCtrl&);
    void processBbuUpgradeRsp(OamMessageProtocol_SoftwareUpgradRsp&, BbuCtrl&);
    void processEquitResetRsp(OamMessageProtocol_EquipResetRsp&, BbuCtrl&);
    void processSyncModeSettingRsp(OamMessageProtocol_SyncModeRsp&, BbuCtrl&);
    void processSyncStateRsp(OamMessageProtocol_SyncStatusRsp&, BbuCtrl&);
    void processCellCfgRsp(NmmToX86Protocol_CellConfigRsp& cfgRsp, BbuCtrl&);
    void processGpsStateRsp(OamMessageProtocol_GpsInfoRpt& rpt, BbuCtrl& bbu);
    void processUeRedirectRsp(NmmToX86Protocol_UeRedirectRsp& msg, BbuCtrl&);
    bool shutDownTxPwer(BbuCtrl&);

    bool isTrgByOam_;
    std::map<uint16_t, std::list<EmBaseProcedure*> > procHandlers_;
};

#endif
